package service.configuration.xstream;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import com.thoughtworks.xstream.converters.basic.BooleanConverter;

import service.configuration.IApplicationConfig;

@XStreamAlias("application")
public class ApplicationConfig implements IApplicationConfig {
	
	@XStreamAlias("password")
	public class PasswordConfig {
		private Integer min;
		private Integer max;
		public Integer getMin() {
			return min;
		}
		public void setMin(Integer min) {
			this.min = min;
		}
		public Integer getMax() {
			return max;
		}
		public void setMax(Integer max) {
			this.max = max;
		}
	}
	
	private PasswordConfig password;
	private String url;
	private String adminMail;

	@XStreamConverter(value=BooleanConverter.class, booleans={false}, strings={"true", "false"})
	private boolean debug;
	
	public ApplicationConfig(int min , int max) {
		password.setMin(min);
		password.setMax(max);
	}
	
	public Integer getPasswordMinSize() {
		return password.getMin();
	}
	
	public Integer getPasswordMaxSize() {
		return password.getMax();
	}

	public String getUrl() {
		return url;
	}

	public boolean isDebug() {
		return debug;
	}

	public String getAdminMail() {
		return adminMail;
	}
	
}
